using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using com.paypal.soap.api;
using IGlobalist.Chat.Engine;



namespace IGlobalist.Cms.Common
{
    public class BasePage : Page
    {
        //protected override void OnLoad(EventArgs e)
        //{
        //    base.OnLoad(e);

        //}


        public log4net.ILog Logger
        {
            get { return log4net.LogManager.GetLogger("File"); }
        }
        public void TestLog()
        {
            Logger.Error("This is an error", new Exception("xfdfdfd"));

        }

       


        public string DataRootVirtualPath
        {
            get
            {
                return ConfigurationSettings.AppSettings.Get("RootDataFolder");
            }
        }
        public string DataRootPhysicalPath
        {
            get
            {
                string path = HttpContext.Current.Server.MapPath(DataRootVirtualPath);
                if (!System.IO.Directory.Exists(path))
                    System.IO.Directory.CreateDirectory(path);
                return path;
            }
        }

        public string FolderUploadVirtualPath
        {
            get
            {
                return DataRootVirtualPath + "/FileUpload";
            }
        }

        public string FolderPhotoVirtualPath
        {
            get
            {
                return DataRootVirtualPath + "/Photos";
            }
        }

        public string FolderAdVirtualPath
        {
            get
            {
                return DataRootVirtualPath + "/Ads";
            }
        }

        public string FolderForumVirtualPath
        {
            get
            {
                return DataRootVirtualPath + "/Forum";
            }
        }
        public string FolderUploadPhysicalPath
        {
            get
            {
                string path = HttpContext.Current.Server.MapPath(FolderUploadVirtualPath);
                if (!System.IO.Directory.Exists(path))
                    System.IO.Directory.CreateDirectory(path);
                return path;
            }
        }

        public string FolderPhotoPhysicalPath
        {
            get
            {
                string path = HttpContext.Current.Server.MapPath(FolderPhotoVirtualPath);
                if (!System.IO.Directory.Exists(path))
                    System.IO.Directory.CreateDirectory(path);
                return path;
            }
        }
        public string FolderForumPhysicalPath
        {
            get
            {
                string path = HttpContext.Current.Server.MapPath(FolderForumVirtualPath);
                if (!System.IO.Directory.Exists(path))
                    System.IO.Directory.CreateDirectory(path);
                return path;
            }
        }
        public string FolderAdPhysicalPath
        {
            get
            {
                string path = HttpContext.Current.Server.MapPath(FolderAdVirtualPath);
                if (!System.IO.Directory.Exists(path))
                    System.IO.Directory.CreateDirectory(path);
                return path;
            }
        }

        public string FolderUserProfileVirtualPath
        {
            get
            {
                return DataRootVirtualPath + "/UserProfile";
            }
        }

        public string FolderUserProfilePhysicalPath
        {
            get
            {
                string path = HttpContext.Current.Server.MapPath(FolderUserProfileVirtualPath);
                if (!System.IO.Directory.Exists(path))
                    System.IO.Directory.CreateDirectory(path);
                return path;
            }
        }

        #region ---------------Properties--------------------------
        public AbstractResponseType PayPalResponse
        {
            get
            {
                return (AbstractResponseType)this.Session[Constants.RESPONSE_SESSION_KEY];
            }
            set
            {
                this.Session[Constants.RESPONSE_SESSION_KEY] = value;
            }
        }

        protected bool IsTransactionSuccessful
        {
            get
            {
                return DataUtils.IsSuccessfull(this.PayPalResponse.Ack);
            }
        }
        protected string TransactionID
        {
            get
            {
                return this.Request.QueryString.Get(Constants.TRANSACTIONID_PARAM);
            }
        }

        public PaymentActionCodeType PaymentAction
        {
            get
            {
                if (this.Session[Constants.PAYMENTACTIONTYPE_SESSION_KEY] == null)
                {
                    this.PaymentAction = PaymentActionCodeType.Sale;
                }
                return (PaymentActionCodeType)this.Session[Constants.PAYMENTACTIONTYPE_SESSION_KEY];
            }
            set
            {
                Session[Constants.PAYMENTACTIONTYPE_SESSION_KEY] = value;
            }
        }

        #endregion


        

        
    }
}
